package com.njzxw.yoga.yogaApi.controller;

import com.njzxw.fs.commonutil.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import com.njzxw.yoga.yogaApi.server.TeacherAttrServer;
import com.njzxw.yoga.yogaApi.bean.TeacherAttrBean;
import com.njzxw.fs.commonutil.bean.BaseBean;
import org.springframework.validation.BindingResult;
import com.njzxw.fs.commonutil.web.ReturnMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("teacherAttr")
public class TeacherAttrController extends BaseController{

    @Autowired
    private TeacherAttrServer teacherAttrServer;

    /**
     * 分页获取数据
     */
    @RequestMapping("/queryPage")
    public ReturnMap queryPage(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({TeacherAttrBean.QueryPage.class, BaseBean.CheckAuthority.class}) TeacherAttrBean teacherAttrBean, BindingResult bindingResult) {
        return teacherAttrServer.queryPage(request,response,teacherAttrBean);
    }

    /**
     * 获取但一条数据信息
     */
    @RequestMapping("/queryId")
    public ReturnMap queryId(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({TeacherAttrBean.QueryId.class,BaseBean.CheckId.class, BaseBean.CheckAuthority.class}) TeacherAttrBean teacherAttrBean, BindingResult bindingResult) {
        return teacherAttrServer.queryId(request,response,teacherAttrBean);
    }


    /**
     * 删除数据信息
     */
    @RequestMapping("/delete")
    public ReturnMap delete(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({TeacherAttrBean.Delete.class, BaseBean.CheckAuthority.class}) TeacherAttrBean teacherAttrBean, BindingResult bindingResult) {
        return teacherAttrServer.delete(request,response,teacherAttrBean);
    }

    /**
     * 插入数据信息
     */
    @RequestMapping("/save")
    public ReturnMap save(HttpServletRequest request, HttpServletResponse response,@RequestBody @Validated({TeacherAttrBean.Save.class, BaseBean.CheckAuthority.class, BaseBean.CheckShopId.class,
            BaseBean.CheckMerchantId.class})
            TeacherAttrBean
            teacherAttrBean, BindingResult bindingResult) {
        return teacherAttrServer.save(request,response,teacherAttrBean);
    }

}